package co.wangdao.xingshaoye.utils;

import android.content.Context;
import android.widget.Toast;

public class ToastUtil {
    public static Toast showToast(Context context, String msg) {
        Toast toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        toast.show();
        return toast;
    }

    public static Toast showToast(Context context, int resId) {
        Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
        toast.show();
        return toast;
    }

    static Toast toast;

    public static Toast showOnSameToast(Context context, int resId) {
        if (toast == null) {
            toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
        }
        toast.setText(resId);
        toast.show();
        return toast;
    }

    public static Toast showOnSameToast(Context context, String msg) {
        if (toast == null) {
            toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        }
        toast.setText(msg);
        toast.show();
        return toast;
    }
}
